import huffman.DataInputStreamEx;
import huffman.HuffmanIn;
import huffman.HuffmanOut;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;




public class Main {


	
//	System.out.println(bf.)
//	/**
//	 * @param args
//	 */
	public static void main(String[] args) throws FileNotFoundException, IOException {
		
				try {
					String in = "Huffman.pdf";
					String out = "Huffman.test";
					
			System.out.println("COMPRESSION");		
			new HuffmanIn(in).compressTo(out);

			System.out.println("DECOMPRESSION");	
			new HuffmanOut(out).uncompressTo("HuffmanNew.pdf");
			
			System.out.println("FIN");	
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}

	public static void compare(String s, String s2) throws IOException {
		FileInputStream in = new FileInputStream(s);
		FileInputStream out = new FileInputStream(s2);
		byte b1[] = new byte[1];
		byte b2[] = new byte[1];
		while(in.available() > 0 || out.available() > 0) {
			in.read(b1);
			out.read(b2);
			if(b1[0] != b2[0]) {
				System.out.println("ERRRR: " + in.getChannel().position() + " " + b1[0]);
			}
		}
	}
}
